"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SocketClientReqManager = void 0;
const Config_1 = require("../../config/Config");
const ServerConfig_1 = require("../../config/ServerConfig");
const Logger_1 = require("../utils/Logger");
const WebSocketClientManager_1 = require("./WebSocketClientManager");
const ProtoManager_1 = require("../../lib/net/protobuf/ProtoManager");
const jhaoproto_1 = require("../../lib/net/protobuf/jhaoproto");
class SocketClientReqManager {
    onSocketMsg(client, baseMsg) {
    }
    req_server_internal_Login(serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            let client = WebSocketClientManager_1.WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            let account = Config_1.Config.serverType + "-" + ServerConfig_1.ServerConfig.nowServerConfig.id;
            let send_data = {
                account: account,
                pass: "sjh666666",
            };
            let send_obj = {
                cmd_index: jhaoproto_1.JhaoProto.CmdIndex.server_internal_Login,
                "en_proto_ctor": jhaoproto_1.JhaoProto.req_server_internal_Login,
                "data": send_data,
                "callback": (respData) => {
                    if (respData.errorCode == jhaoproto_1.JhaoProto.ErrorCodeWs.Suc) {
                    }
                    else {
                        Logger_1.Logger.warn("req_server_internal_Login", respData.errorCode, respData.errorMsg);
                    }
                }
            };
            Logger_1.Logger.log("req_server_internal_Login", send_obj, serverConfig);
            client.sendProto(send_obj);
        });
    }
    req_server_internal_kill_all_users(serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            let client = WebSocketClientManager_1.WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            let send_data = {};
            let send_obj = {
                cmd_index: jhaoproto_1.JhaoProto.CmdIndex.server_internal_kill_all_users,
                "en_proto_ctor": jhaoproto_1.JhaoProto.req_server_internal_kill_all_users,
                "data": send_data,
                "callback": (respData) => {
                    if (respData.errorCode == jhaoproto_1.JhaoProto.ErrorCodeWs.Suc) {
                    }
                    else {
                        Logger_1.Logger.warn("req_server_internal_kill_all_users", respData.errorCode, respData.errorMsg);
                    }
                }
            };
            client.sendProto(send_obj);
        });
    }
    req_server_internal_set_server_status(status, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            let client = WebSocketClientManager_1.WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            let send_data = {
                status: status
            };
            let send_obj = {
                cmd_index: jhaoproto_1.JhaoProto.CmdIndex.server_internal_set_server_status,
                "en_proto_ctor": jhaoproto_1.JhaoProto.req_server_internal_set_server_status,
                "data": send_data,
                "callback": (respData) => {
                    if (respData.errorCode == jhaoproto_1.JhaoProto.ErrorCodeWs.Suc) {
                    }
                    else {
                        Logger_1.Logger.warn("req_server_internal_set_server_status", respData.errorCode, respData.errorMsg);
                    }
                }
            };
            client.sendProto(send_obj);
        });
    }
    req_server_internal_get_server_status(serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            return new Promise((resolve, reject) => {
                let client = WebSocketClientManager_1.WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
                let send_data = {};
                let send_obj = {
                    cmd_index: jhaoproto_1.JhaoProto.CmdIndex.server_internal_get_server_status,
                    "en_proto_ctor": jhaoproto_1.JhaoProto.req_server_internal_get_server_status,
                    "data": send_data,
                    "callback": (respData) => {
                        if (respData.errorCode == jhaoproto_1.JhaoProto.ErrorCodeWs.Suc) {
                            let protoPack = ProtoManager_1.ProtoManager.instance.decode(jhaoproto_1.JhaoProto.resp_server_internal_get_server_status, respData.data);
                            Logger_1.Logger.log("req_server_internal_get_server_status", protoPack);
                            resolve(protoPack.status);
                        }
                        else {
                            Logger_1.Logger.log("req_server_internal_get_server_status", respData.errorCode, respData.errorMsg);
                            resolve(ServerConfig_1.ServerConfig.Status_Type.Weihu);
                        }
                    }
                };
                client.sendProto(send_obj);
            });
        });
    }
    req_server_internal_update_online(userids, server_id, serverType, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            let client = WebSocketClientManager_1.WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            let send_data = {
                userids: userids,
                serverId: server_id,
                serverType: serverType
            };
            let send_obj = {
                cmd_index: jhaoproto_1.JhaoProto.CmdIndex.server_internal_update_online,
                "en_proto_ctor": jhaoproto_1.JhaoProto.req_server_internal_update_online,
                "data": send_data,
                "callback": (respData) => {
                    if (respData.errorCode == jhaoproto_1.JhaoProto.ErrorCodeWs.Suc) {
                    }
                    else {
                        Logger_1.Logger.warn("req_server_internal_update_online", respData.errorCode, respData.errorMsg);
                    }
                }
            };
            client.sendProto(send_obj);
        });
    }
    req_server_internal_is_in_server(account, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            return new Promise((resolve, reject) => {
                let client = WebSocketClientManager_1.WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
                let send_data = {
                    account: account
                };
                let send_obj = {
                    cmd_index: jhaoproto_1.JhaoProto.CmdIndex.server_internal_is_in_server,
                    "en_proto_ctor": jhaoproto_1.JhaoProto.req_server_internal_is_in_server,
                    "data": send_data,
                    "callback": (respData) => {
                        if (respData.errorCode == jhaoproto_1.JhaoProto.ErrorCodeWs.Suc) {
                            let protoPack = ProtoManager_1.ProtoManager.instance.decode(jhaoproto_1.JhaoProto.resp_server_internal_is_in_server, respData.data);
                            resolve(protoPack.isIn);
                        }
                        else {
                            Logger_1.Logger.warn("req_server_internal_is_in_server", respData.errorCode, respData.errorMsg);
                            resolve(false);
                        }
                    }
                };
                client.sendProto(send_obj);
            });
        });
    }
    req_server_internal_is_user_online(userid, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            return new Promise((resolve, reject) => {
                let client = WebSocketClientManager_1.WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
                let send_data = {
                    userid: userid
                };
                let send_obj = {
                    cmd_index: jhaoproto_1.JhaoProto.CmdIndex.server_internal_is_user_online,
                    "en_proto_ctor": jhaoproto_1.JhaoProto.req_server_internal_is_user_online,
                    "data": send_data,
                    "callback": (respData) => {
                        if (respData.errorCode == jhaoproto_1.JhaoProto.ErrorCodeWs.Suc) {
                            let protoPack = ProtoManager_1.ProtoManager.instance.decode(jhaoproto_1.JhaoProto.resp_server_internal_is_user_online, respData.data);
                            resolve(protoPack.isOnline);
                        }
                        else {
                            Logger_1.Logger.warn("req_server_is_user_online", respData.errorCode, respData.errorMsg);
                            resolve(false);
                        }
                    }
                };
                client.sendProto(send_obj);
            });
        });
    }
    req_server_onlie_club(clubid, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            // let data: object = {
            //     "protoName": ProtoServerConfig.req_server_onlie_club,
            //     "clubid": clubid,
            // }
            // let client: WebSocketClient = WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            // let respData = await client.sendDataAsync(data);
            // Logger.log("req_server_onlie_club resp=", respData)
            // return respData
        });
    }
    req_server_notify_delete_club_user(clubid, userid, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            // let data: object = {
            //     "protoName": ProtoServerConfig.req_server_notify_delete_club_user,
            //     "clubid": clubid,
            //     "userid": userid
            // }
            // let client: WebSocketClient = WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            // let respData = await client.sendDataAsync(data);
            // Logger.log("req_server_notify_delete_club_user resp=", respData)
            // return respData
        });
    }
    req_server_notify_set_club_quanxian(clubid, userid, quanxian, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            // let data: object = {
            //     "protoName": ProtoServerConfig.req_server_notify_set_club_quanxian,
            //     "clubid": clubid,
            //     "userid": userid,
            //     "quanxian": quanxian
            // }
            // let client: WebSocketClient = WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            // let respData = await client.sendDataAsync(data);
            // Logger.log("req_server_notify_set_club_quanxian resp=", respData)
            // return respData
        });
    }
    req_server_notify_club_freeze(clubid, userid, user_state, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            // let data: object = {
            //     "protoName": ProtoServerConfig.req_server_notify_club_freeze,
            //     "clubid": clubid,
            //     "userid": userid,
            //     "user_state": user_state
            // }
            // let client: WebSocketClient = WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            // let respData = await client.sendDataAsync(data);
            // Logger.log("req_server_notify_club_freeze resp=", respData)
            // return respData
        });
    }
    req_server_notify_set_club_admin(clubid, userid, actor, quanxian, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            // let data: object = {
            //     "protoName": ProtoServerConfig.req_server_notify_set_club_quanxian,
            //     "clubid": clubid,
            //     "userid": userid,
            //     "actor": actor,
            //     "quanxian": quanxian
            // }
            // let client: WebSocketClient = WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            // let respData = await client.sendDataAsync(data);
            // Logger.log("req_server_notify_set_club_quanxian resp=", respData)
            // return respData
        });
    }
    req_server_insertRoomTemplateModel(serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            let client = WebSocketClientManager_1.WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            let send_data = {};
            let send_obj = {
                cmd_index: jhaoproto_1.JhaoProto.CmdIndex.server_internal_club_create_room_template,
                "en_proto_ctor": jhaoproto_1.JhaoProto.req_server_internal_club_create_room_template,
                "data": send_data,
                "callback": (respData) => {
                    if (respData.errorCode == jhaoproto_1.JhaoProto.ErrorCodeWs.Suc) {
                    }
                    else {
                        Logger_1.Logger.warn("req_server_insertRoomTemplateModel", respData.errorCode, respData.errorMsg);
                    }
                }
            };
            client.sendProto(send_obj);
        });
    }
    req_server_internal_club_delete_room_template(id, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            let client = WebSocketClientManager_1.WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            let send_data = {
                id: id,
            };
            let send_obj = {
                cmd_index: jhaoproto_1.JhaoProto.CmdIndex.server_internal_club_delete_room_template,
                "en_proto_ctor": jhaoproto_1.JhaoProto.req_server_internal_club_delete_room_template,
                "data": send_data,
                "callback": (respData) => {
                    if (respData.errorCode == jhaoproto_1.JhaoProto.ErrorCodeWs.Suc) {
                    }
                    else {
                        Logger_1.Logger.warn("req_server_internal_club_delete_room_template", respData.errorCode, respData.errorMsg);
                    }
                }
            };
            client.sendProto(send_obj);
        });
    }
    req_server_internal_createRoom(room, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            let client = WebSocketClientManager_1.WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            let send_data = {
                room: room
            };
            let send_obj = {
                cmd_index: jhaoproto_1.JhaoProto.CmdIndex.server_internal_createRoom,
                "en_proto_ctor": jhaoproto_1.JhaoProto.req_server_internal_createRoom,
                "data": send_data,
                "callback": (respData) => {
                    if (respData.errorCode == jhaoproto_1.JhaoProto.ErrorCodeWs.Suc) {
                    }
                    else {
                        Logger_1.Logger.warn("req_server_internal_createRoom", respData.errorCode, respData.errorMsg);
                    }
                }
            };
            client.sendProto(send_obj);
        });
    }
    req_server_joinRoom(room_id, player, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            // let data: object = {
            //     "protoName": ProtoServerConfig.req_server_joinRoom,
            //     "room_id": room_id,
            //     "player": player
            // }
            // Logger.log("req_server_joinRoom", data)
            // let client: WebSocketClient = WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            // client.sendDataAsync(data);
        });
    }
    req_server_leave_room(room, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            // let data: object = {
            //     "protoName": ProtoServerConfig.req_server_leave_room,
            //     "room": room,
            // }
            // Logger.log("req_server_leave_room", data)
            // let client: WebSocketClient = WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            // client.sendDataAsync(data);
        });
    }
    req_server_deleteRoom(room_id, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            // let data: object = {
            //     "protoName": ProtoServerConfig.req_server_deleteRoom,
            //     "room_id": room_id,
            // }
            // Logger.log("req_server_deleteRoom", data)
            // let client: WebSocketClient = WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            // client.sendDataAsync(data);
        });
    }
    req_server_notify_game_start(room, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            // let data: object = {
            //     "protoName": ProtoServerConfig.req_server_notify_game_start,
            //     "room": room,
            // }
            // Logger.log("req_server_notify_game_start", data)
            // let client: WebSocketClient = WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            // client.sendDataAsync(data);
        });
    }
    req_server_notify_update_gems(userid, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            // let data: object = {
            //     "protoName": ProtoServerConfig.req_server_notify_update_gems,
            //     "userid": userid,
            // }
            // // Logger.log("req_server_notify_update_gems", data)
            // let client: WebSocketClient = WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            // client.sendDataAsync(data);
        });
    }
    req_server_notify_update_coins(userid, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            // let data: object = {
            //     "protoName": ProtoServerConfig.req_server_notify_update_coins,
            //     "userid": userid,
            // }
            // // Logger.log("req_server_notify_update_gems", data)
            // let client: WebSocketClient = WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            // client.sendDataAsync(data);
        });
    }
    req_server_notify_update_income(userid, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            // let data: object = {
            //     "protoName": ProtoServerConfig.req_server_notify_update_income,
            //     "userid": userid,
            // }
            // // Logger.log("req_server_notify_update_gems", data)
            // let client: WebSocketClient = WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            // client.sendDataAsync(data);
        });
    }
    req_server_notify_update_meili(userid, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            // let data: object = {
            //     "protoName": ProtoServerConfig.req_server_notify_update_meili,
            //     "userid": userid,
            // }
            // // Logger.log("req_server_notify_update_gems", data)
            // let client: WebSocketClient = WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            // client.sendDataAsync(data);
        });
    }
    req_server_notify_update_lv(userid, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            // let data: object = {
            //     "protoName": ProtoServerConfig.req_server_notify_update_lv,
            //     "userid": userid,
            // }
            // // Logger.log("req_server_notify_update_gems", data)
            // let client: WebSocketClient = WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            // client.sendDataAsync(data);
        });
    }
    req_server_notify_update_invite(userid, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            // let data: object = {
            //     "protoName": ProtoServerConfig.req_server_notify_update_invite,
            //     "userid": userid,
            // }
            // // Logger.log("req_server_notify_update_gems", data)
            // let client: WebSocketClient = WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            // client.sendDataAsync(data);
        });
    }
    req_server_notify_update_img(userid, imgurl, upload_pic_type, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            // let data: object = {
            //     "protoName": ProtoServerConfig.req_server_notify_update_img,
            //     "userid": userid,
            //     "imgurl": imgurl,
            //     "upload_pic_type": upload_pic_type,
            // }
            // // Logger.log("req_server_notify_update_gems", data)
            // let client: WebSocketClient = WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            // client.sendDataAsync(data);
        });
    }
    req_server_notify_club_open_or_close(clubid, state, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            // let data: object = {
            //     "protoName": ProtoServerConfig.req_server_notify_club_open_or_close,
            //     "clubid": clubid,
            //     "state": state,
            // }
            // // Logger.log("req_server_notify_update_gems", data)
            // let client: WebSocketClient = WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            // client.sendDataAsync(data);
        });
    }
    req_server_delete_room_by_hall(room_id, nick_name, serverConfig) {
        return __awaiter(this, void 0, void 0, function* () {
            // let data: object = {
            //     "protoName": ProtoServerConfig.req_server_delete_room_by_hall,
            //     "room_id": room_id,
            //     "nick_name": nick_name,
            // }
            // // Logger.log("req_server_notify_update_gems", data)
            // let client: WebSocketClient = WebSocketClientManager.instance.getWebSocketClientByServerConfig(serverConfig);
            // client.sendDataAsync(data);
        });
    }
}
exports.SocketClientReqManager = SocketClientReqManager;
SocketClientReqManager.instance = new SocketClientReqManager();
